﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreData;
using EntityData;
namespace Services
{
   public partial class vwusersService
    {
        readonly IvwusersEntity entity;

        public vwusersService()
       {
           this.entity = new vwusersEntity() ;
       }

       #region Main Method

       

       /// <summary>
       /// Get by ID
       /// </summary>
       /// <param name="_id"></param>
       /// <returns></returns>
       public CoreData.vwusers GetByID(long _id)
       {
           try
           {
              

               var data = entity.GetById(_id, Table.vwusers.ToString());          
               return data;
           }
           catch { return null; }
       }

       /// <summary>
       /// Get List
       /// </summary>
       /// <returns></returns>
       public IList<CoreData.vwusers> GetList()
       {
           try
           {
               var list = entity.GetAll(Table.vwusers.ToString()).ToList();        
               return list;
           }
           catch { return null; }

       }

       /// <summary>
       /// Get List with Linq
       /// </summary>
       /// <returns></returns>
       public IList<CoreData.vwusers> GetListByLINQ(Func<CoreData.vwusers, Boolean> _where)
       {
           try
           {
               return entity.GetMany(_where, Table.vwusers.ToString()).ToList();
           }
           catch { return null; }
       }
       /// <summary>
       /// Get One with Linq
       /// </summary>
       /// <returns></returns>
       public CoreData.vwusers GetOneByLINQ(Func<CoreData.vwusers, Boolean> _where)
       {
           try
           {
               return entity.Get(_where, Table.vwusers.ToString());
           }
           catch { return null; }
       }

       /// <summary>
       /// Get List with search string
       /// </summary>
       /// <returns></returns>
       public IList<CoreData.vwusers> GetList(string _searchstring)
       {
           //search theo tieu chi nao do         
           try
           {

               var list = entity.GetBySearchString(_searchstring, Table.vwusers.ToString()).ToList();
              
               return list;
           }
           catch { return null; }
       }


       /// <summary>
       /// Delete
       /// </summary>
       /// <param name="_model"></param>
       /// <returns></returns>
       public bool Delete(object _model)
       {
           try
           {
               entity.Delete((CoreData.vwusers)_model, Table.vwusers.ToString());
               return true;
           }
           catch { return false; }
       }

       #endregion



        #region Other Method
        #endregion
    }
}
